import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:library_base/ext/theme_data_ext.dart';
import 'package:library_base/global/multi_language.dart';
import 'package:library_base/utils/get_util.dart';
import 'package:library_base/utils/theme_util.dart';
import 'package:library_base/utils/widget_generate_util.dart';

class BottomOptionDialog extends StatefulWidget {
  BottomOptionDialog({
    Key? key,
  }) : super(key: key);

  @override
  State<BottomOptionDialog> createState() => _BottomOptionDialogState();
}

class _BottomOptionDialogState extends State<BottomOptionDialog> {
  void Function(String)? callback;

  List<String> actionStr = [MultiLanguage.saveAndSubmit.tr, MultiLanguage.saveDraft.tr];

  String cancelStr = MultiLanguage.cancel.tr;

  @override
  void initState() {
    super.initState();
    var arguments = Get.arguments;
    callback = arguments['CallBack'];
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        GetHelper.back();
      },
      child: Container(
        color: Colors.transparent,
        child: GenerateWidgetUtil.roundWidget(
            width: double.infinity,
            alignment: Alignment.bottomCenter,
            child: Container(
              width: double.infinity,
              clipBehavior: Clip.hardEdge,
              decoration: BoxDecoration(
                color: ThemeUtil.getTheme().colorScheme.secondary,
                borderRadius: const BorderRadius.only(
                    topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0)),
              ),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  GestureDetector(
                    onTap: () {
                      callback?.call(actionStr[0]);
                    },
                    child: Container(
                      color: Colors.transparent,
                      alignment: Alignment.center,
                      width: double.infinity,
                      height: 99.w,
                      child: AutoSizeText(
                        actionStr[0],
                        style: TextStyle(
                            fontSize: 30.sp, color: ThemeUtil.getTheme().fourthTextColor()),
                      ),
                    ),
                  ),
                  Container(
                      width: double.infinity,
                      height: 0.7,
                      color: ThemeUtil.getTheme().dividingLineColor()),
                  GestureDetector(
                    onTap: () {
                      callback?.call(actionStr[1]);
                    },
                    child: Container(
                      color: Colors.transparent,
                      alignment: Alignment.center,
                      width: double.infinity,
                      height: 99.w,
                      child: AutoSizeText(
                        actionStr[1],
                        style: TextStyle(
                            fontSize: 30.sp, color: ThemeUtil.getTheme().normalTextColor()),
                      ),
                    ),
                  ),
                  Container(
                      width: double.infinity,
                      height: 14,
                      color: ThemeUtil.getTheme().dividingLineColor()),
                  GestureDetector(
                    onTap: () {
                      callback?.call(cancelStr);
                      GetHelper.back();
                    },
                    child: Container(
                      color: Colors.transparent,
                      alignment: Alignment.center,
                      width: double.infinity,
                      height: 165.w,
                      child: AutoSizeText(
                        cancelStr,
                        style: TextStyle(
                            fontSize: 30.sp, color: ThemeUtil.getTheme().fourthTextColor()),
                      ),
                    ),
                  )
                ],
              ),
            )),
      ),
    );
  }
}
